$(function() {

    function sort_li(arr,num){
        arr.filter(function(i){
            if((i+1)%num==0){
                $(this).addClass('no-mr');
            }
        });
    }
    function fl_li(arr,num){
        arr.filter(function(i){
            if((i+1)%num==0){
                $(this).css('float','right');
            }
        });
    }
    function hide_li(arr,num){
        arr.filter(function(i){
            if((i+1)>num){
                $(this).hide();
            }
        });
    }


    var numBtn = true;
    $(window).scroll(function() {
        var sT = $(document).scrollTop();
        if(sT > 200) {
            //$('.i-about .top').addClass('animated').addClass('fadeInUp');
        }
        if(sT > 900) {
            if(numBtn) {
                setTimeout(function() {
                    var aNum = $('.about-bar-list li i');
                    aNum.filter(function() {
                        var maxNum = $(this).attr('num'),
                            $this = this;
                        $this.i = 0;
                        $this.speed = Math.ceil(maxNum / 100);
                        $this.timer = null;
                        $this.timer = setInterval(function() {
                            $this.innerText = $this.i;
                            if($this.i > (maxNum - $this.speed)) {
                                clearInterval($this.timer);
                            }
                            $this.i = $this.i + $this.speed;
                        }, 20);
                    });
                }, 800);
            }
            numBtn = false;
        }
    });

    

    var swiper = new Swiper('#index-body .i-product .productBox .swiper-container', {
        centeredSlides: false,
        slidesPerView: 3,
        speed: 1100,
        spaceBetween: 30,
        autoplay:{
          disableOnInteraction: false,
        },
        loop: true,
        // 如果需要前进后退按钮
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
        breakpoints: {
            1100:{
              slidesPerView: 3,
              spaceBetween: 20,
            },
            768:{
              slidesPerView: 1,
              spaceBetween: 20,
            },
        }
    });

    var swiper = new Swiper('#index-body .i-why .whyBox .swiper-container', {
        centeredSlides: false,
        slidesPerView: 3,
        speed: 1100,
        spaceBetween: 80,
        autoplay:{
          disableOnInteraction: false,
        },
        loop: true,
        breakpoints: {
            1100:{
              slidesPerView: 3,
              spaceBetween: 50,
            },
            768:{
              slidesPerView: 1,
              spaceBetween: 20,
            },
        }
    });

    var swiper = new Swiper('#index-body .i-news .newsBox .swiper-container', {
        centeredSlides: false,
        slidesPerView: 2,
        speed: 1100,
        spaceBetween: 80,
        autoplay:{
          disableOnInteraction: false,
        },
        loop: true,
        breakpoints: {
            1100:{
              slidesPerView: 2,
              spaceBetween: 40,
            },
            768:{
              slidesPerView: 1,
              spaceBetween: 20,
            },
        }
    });

});